<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\User */

$this->title = $model->username;
$this->params['breadcrumbs'][] = ['label' => '会员管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box">
    <div class="box-header">
        <div class="btn-group">
            <?= Html::a('<i class="fa fa-pencil"></i>', ['update', 'id' => $model->id], ['class' => 'btn btn-default']) ?>
            <?= Html::a('<i class="fa fa-trash-o"></i>', ['delete', 'id' => $model->id], [
                'class' => 'btn btn-default',
                'data' => [
                    'confirm' => '您确定要删除该用户吗？',
                    'method' => 'post',
                ],
            ]) ?>
            <!-- /.btn-group -->
        </div>
        <div class="pull-right">
            <?= Html::a('<i class="fa fa-reply"></i>', ['index'], ['class' => 'btn btn-default']) ?>
        </div>
    </div>
    <!-- /.box-header -->
    <div class="box-body no-padding">
        <h2>会员基本信息</h2>
        <?= DetailView::widget([
            'model' => $model,
            'attributes' => [
                'id',
                'username',
                'idcard',
                'realname',
                'money',
                [
                    'attribute' => 'wechat_id',
                    'value' => function($model){
                        /** @var \common\models\User $model */
                        return $model->wechatUser->nickname;
                    }
                ],
                [
                    'attribute' => 'sex',
                    'value' => function($model){
                        return $model->sex == 1 ? '男' : '女';
                    }
                ],
                [
                    'attribute' => 'group_id',
                    'value' => function($model){
                        /** @var \common\models\User $model */
                        return $model->group->group_name;
                    }
                ],
                'mobile',
                'age',
                'address',
                [
                    'attribute' => 'created_at',
                    'format' => ['date', 'php:Y-m-d H:i:s'],
                ],
            ],
        ]) ?>

    </div>
    <!-- /.box-body -->
</div>

<?php
if( $model->userCase ){
    ?>
    <div class="box">
        <!-- /.box-header -->
        <div class="box-body no-padding">
            <h2>会员病史</h2>
            <?= DetailView::widget([
                'model' => $model->userCase,
                'attributes' => [
                    'diagnosis',
                    'sick_time',
                    'medical_history',
                    'irritability_history',
                    'family_history',
                    'hobby',
                    'address'
                ],
            ]) ?>

        </div>
        <!-- /.box-body -->
    </div>
    <?php
}
?>
<?php
if( $model->consignee ){
    ?>
    <div class="box">
        <!-- /.box-header -->
        <div class="box-body no-padding">
            <h2>受托人信息</h2>
            <?= DetailView::widget([
                'model' => $model->consignee,
                'attributes' => [
                    'relation',
                    'realname',
                    'mobile',
                    [
                        'attribute' => 'sex',
                        'value' => function($model){
                            return $model->sex == 1 ? '男' : '女';
                        }
                    ],
                    'idcard',
                    'wechat_name',
                    'email',
                    'address'
                ],
            ]) ?>

        </div>
        <!-- /.box-body -->
    </div>
    <?php
}
?>
